<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数字排序</title>
</head>

<body>
    <h1>数字排序</h1>
    <label for="num1">输入第一个数字:</label>
    <input type="number" id="num1" placeholder="请输入数字">
    <br>
    <label for="num2">输入第二个数字:</label>
    <input type="number" id="num2" placeholder="请输入数字">
    <br>
    <label for="num3">输入第三个数字:</label>
    <input type="number" id="num3" placeholder="请输入数字">
    <br>
    <button onclick="sortNumbers()">排序</button>
    <p id="result"></p>

    <script>
        function sortNumbers() {
            const num1 = parseFloat(document.getElementById('num1').value);
            const num2 = parseFloat(document.getElementById('num2').value);
            const num3 = parseFloat(document.getElementById('num3').value);

            if (isNaN(num1) || isNaN(num2) || isNaN(num3)) {
                document.getElementById('result').textContent = '请输入有效的数字。';
                return;
            }

            const numbers = [num1, num2, num3];
            numbers.sort((a, b) => b - a);
            document.getElementById('result').textContent = `从大到小排序结果: ${numbers.join(', ')}`;
        }
    </script>
</body>

</html>
    